#include<bits/stdc++.h>
using namespace std;
#include<algorithm>

int main(){
    vector<int> arr(3);
    for(int i = 0;i<3;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    string str;
    cin>>str;

    if(str == "ABC") cout<<arr[0]<<" "<<arr[1]<<" "<<arr[2]<<endl;
    if(str == "ACB") cout<<arr[0]<<" "<<arr[2]<<" "<<arr[1]<<endl;
    if(str == "BAC") cout<<arr[1]<<" "<<arr[0]<<" "<<arr[2]<<endl;
    if(str == "BCA") cout<<arr[1]<<" "<<arr[2]<<" "<<arr[0]<<endl;
    if(str == "CAB") cout<<arr[2]<<" "<<arr[0]<<" "<<arr[1]<<endl;
    if(str == "CBA") cout<<arr[2]<<" "<<arr[1]<<" "<<arr[0]<<endl;




    


    return 0;
}